home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / ffccflow / ffccflow.lha / ffccc+flow / ffccc / SORTSP.f < prev    next >
Text File  |  1992-07-31  |  850b  |  31 lines

  1.       SUBROUTINE SORTSP(N1,IARR,N2) 
  2. *-----------------------------------------------------------------------
  3. *  Sorts integers, suppresses multiple occurrences  
  4. *  Input
  5. *  N1       = no. of integers   
  6. *  Input/Output 
  7. *  IARR     = array containing integers 
  8. *  Output   
  9. *  N2       = new number of integers
  10. *-----------------------------------------------------------------------
  11.       DIMENSION IARR(*) 
  12.    10 CONTINUE  
  13.       IND=0 
  14.       DO 20 J=2,N1  
  15.          IF (IARR(J).LT.IARR(J-1))  THEN
  16.             K=IARR(J)   
  17.             IARR(J)=IARR(J-1)   
  18.             IARR(J-1)=K 
  19.             IND=1   
  20.          ENDIF  
  21.    20 CONTINUE  
  22.       IF (IND.NE.0) GOTO 10 
  23.       N2=MIN(N1,1)  
  24.       DO 30 J=2,N1  
  25.          IF (IARR(J).GT.IARR(J-1))  THEN
  26.             N2=N2+1 
  27.             IARR(N2)=IARR(J)
  28.          ENDIF  
  29.    30 CONTINUE  
  30.       END   
  31.